#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
  struct ListNode {
      int val;
      struct ListNode *next;
  };
 
struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB) {

    struct ListNode* pa = headA;

    struct ListNode* pb = headB;

    while (pa != pb)

    {

        pa = pa->next;

        pb = pb->next;

        if ((pa == NULL) && (pb == NULL))

        {

            return NULL;

        }

        if (pa == NULL)

        {

            pa = headB;

        }
        if (pb == NULL)
        {
            pb = headA;
        }
    }

    return pa;

}
int main()
{
    struct ListNode A;
    struct ListNode B;
    getIntersectionNode(&A,&B);
    return  0;
}